package com.spring.membercardapi.web.controller;



import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.codehaus.jackson.map.util.JSONPObject;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


















import com.spera.shopoa.util.ShopOaSessionUtil;
import com.spring.membercardapi.web.model.ContractUpdate;
import com.spring.membercardapi.web.requestmodel.ApplicationUpdate;
//import com.spring.iosservice.web.service.IosQuestService;
import com.spring.membercardapi.web.service.MemberCardApiService;
import com.spring.security.core.annotation.OaRestPermission;
import com.spring.security.core.util.ApplicationUtils;
import com.spring.security.web.model.BaseResult;
import com.spring.tools.MyTools;
@Controller
@RequestMapping(value = "/memberCardApi")
public class MemberCardApiController {
	
	@Resource
	private MemberCardApiService memberCardApiService;
	

	//获取会员类型信息接口
	@RequestMapping(value = "/getCardTypeList")
	@ResponseBody
    public Object getCardTypeList(HttpServletRequest request,String callback) {
    	Map<String,Object> m  = memberCardApiService.getCardTypeList();
        if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }
    }
	
	//获取套餐详细信息接口
	@RequestMapping(value = "/getPackageDetail")
	@ResponseBody
    public Object getPackageDetail(String package_id,HttpServletRequest request,String callback) {
    	Map<String,Object> m  = memberCardApiService.getPackageDetail(package_id);
        if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }
    }
	//棰勭害浼氬憳
	/*@RequestMapping(value = "/applyCard")
	@ResponseBody
    public Object applyCard(String token,String family_member_id,String baby_birthday,String info_source_code,
    		String card_type_code,String region_id,String coupon_code,String apply_way_code,String kids_park_id,String guardians,
    		HttpServletRequest request,String callback) {
    	Map<String,Object> m  = memberCardApiService.getPackageDetail(token, family_member_id, baby_birthday, info_source_code,
        		 card_type_code, region_id, coupon_code,apply_way_code, kids_park_id, guardians);
        if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }
    }*/
	
	
	
	
	// 预约会员
	@RequestMapping(value = "/applyCard")
	@ResponseBody
	public Object applyCard(String token,String user_name, String family_member_id,String baby_name,
			String baby_sex_code,String baby_birthday,
			 String info_source_code,
			String card_level_code, String region_id, String coupon_code,
			String apply_way_code, String kids_park_id,String c_family_member_id ,String real_name ,String guardians,String interest_service, String callback) {
		Map<String, Object> m = new HashMap<String, Object>();
		try {
			m = memberCardApiService.insertapplyCard(token, user_name, family_member_id, baby_name,
					baby_sex_code, baby_birthday, info_source_code, card_level_code, 
					region_id, coupon_code, apply_way_code, kids_park_id,c_family_member_id , real_name , guardians,interest_service);
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}
		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	//获取数字字典
		@RequestMapping(value = "/getDataDictionaryList")
		@ResponseBody
	    public Object getDataDictionaryList(String type,HttpServletRequest request,String callback) {
	    	Map<String,Object> m  = memberCardApiService.getDataDictionaryList(type);
	        if(ApplicationUtils.isNotNull(callback)){
	        	return new JSONPObject(callback, m);
	        }else{
	        	return m;
	        }
	    }
	
		/**
		 * 查看入会申请
		 * @param type
		 * @param request
		 * @param callback
		 * @return
		 */
		@RequestMapping(value = "/getApplicationList")
		@ResponseBody
	 public Object getApplicationList(String token,String application_id,HttpServletRequest request,String callback) {
	 	Map<String,Object> m  = memberCardApiService.getApplicationList(token,application_id);
	     if(ApplicationUtils.isNotNull(callback)){
	     	return new JSONPObject(callback, m);
	     }else{
	     	return m;
	     }
	 }
		
	/**
	 * 修改预约会员申请
	 * @param token
	 * @param application_id
	 * @param family_member_id
	 * @param info_source_code
	 * @param card_level_code
	 * @param region_id
	 * @param coupon_code
	 * @param kids_park_id
	 * @param callback
	 * @return
	 */
//	@RequestMapping(value = "/updateApplication")
	@ResponseBody
	public Object updateApplication(String token,
			String application_id, String baby_name,String baby_sex_code,String baby_birthday,
			String info_source_code, String card_level_code, String region_id,
			String coupon_code, String kids_park_id, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.updateApplication(token, application_id, baby_name,
					baby_sex_code, baby_birthday, info_source_code, card_level_code, region_id,
					coupon_code, kids_park_id);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	/**
	 * 修改预约会员申请监护人信息
	 * @param token
	 * @param guardian_id
	 * @param family_member_id
	 * @param callback
	 * @return
	 */
	@RequestMapping(value = "/updateGuardian")
	@ResponseBody
	public Object updateGuardian(String token, String guardian_id,
			String family_member_id,String identity_card,String name,String phone,String member_name, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.updateGuardian(token, guardian_id, family_member_id, identity_card, name, phone, member_name);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	
	/**
	 * 删除预约会员申请监护人信息
	 * @param token
	 * @param guardian_id
	 * @param callback
	 * @return
	 */
	@RequestMapping(value = "/deleteGuardian")
	@ResponseBody
	public Object deleteGuardian(String token, String guardian_id,String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.deleteGuardian(token, guardian_id);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	
	
	
	
	
	
	
	
	/**
	 * 添加预约会员申请监护人信息
	 * @param token
	 * @param membercard_application_id
	 * @param family_member_id
	 * @param callback
	 * @return
	 */
	@RequestMapping(value = "/addApplicationGuardian")
	@ResponseBody
	public Object addApplicationGuardian(String token,String membercard_application_id,String family_member_id,
			String identity_card,String name,String phone,String member_name, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.addApplicationGuardian(token, membercard_application_id, family_member_id, identity_card, name, phone, member_name);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	/**
	 * 取消预约会员申请
	 * @param token
	 * @param membercard_application_id
	 * @param family_member_id
	 * @param callback
	 * @return
	 */
	@RequestMapping(value = "/cancelApplication")
	@ResponseBody
	public Object cancelApplication(String token,String membercard_application_id,String cancel_reason, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.cancelApplication(token, membercard_application_id, cancel_reason);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
		
	/**
	 * 查看自己有的会员卡
	 * @param token
	 * @param membercard_application_id
	 * @param cancel_reason
	 * @param callback
	 * @return
	 */
	 
	@RequestMapping(value = "/getCardList")
	@ResponseBody
	public Object getCardList(String token,String isvalid, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.getCardList(token, isvalid);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	
	@RequestMapping(value = "/getCardDetaiList")
	@ResponseBody
	public Object getCardDetaiList(String token,String membercard_id, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.getCardDetaiList(token, membercard_id);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	/**
	 * 会员消费登记
	 * @param token
	 * @param membercard_id
	 * @param business_type_code
	 * @param amount
	 * @param comment
	 * @param unit_code
	 * @param payment_way_code
	 * @param callback
	 * @return
	 */
	@RequestMapping(value = "/checkOut")
	@ResponseBody
	public Object checkOut(String token,String membercard_id,
			String business_type_code,String package_detail_item_id, String amount, String comment,
			String unit_code, String payment_way_code,String kids_park_id, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.checkOut(token, membercard_id, business_type_code, package_detail_item_id,amount, comment, unit_code, payment_way_code,kids_park_id);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	/**
	 * 查看自己消费记录
	 * @param token
	 * @param membercard_id
	 * @param page_size
	 * @param page_index
	 * @param skip
	 * @param rows
	 * @param callback
	 * @return
	 */
	@RequestMapping(value = "/getConsumeList")
	@ResponseBody
	public Object getConsumeList(String token,String membercard_id,String page_size,
			String page_index,String skip,String rows, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.getConsumeList(token, membercard_id, page_size, page_index, skip, rows);
			
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	@RequestMapping(value = "/getPointBillList")
	@ResponseBody
	public Object getPointBillList(String token,String page_size,
			String page_index,String skip,String rows, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.getPointBillList(token, page_size, page_index, skip, rows);
			
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
		
	@RequestMapping(value = "/createCouponCode")
	@ResponseBody
	public Object createCouponCode(String token, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.createCouponCode(token);
			
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	@RequestMapping(value = "/getMyCouponList")
	@ResponseBody
	public Object getMyCouponList(String token,String isused ,String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.getMyCouponList(token,isused);
			
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
//@RequestBody
	
	@OaRestPermission(value="/consumeBackground/courseSignIn")
	@RequestMapping(value = "/applyCardBackground2",headers = {"content-type=application/json"})
	@ResponseBody
	public Object applyCardBackground(@RequestBody Map<String,Object> obj,String callback,HttpServletRequest request) {
			
//		,String real_name, String phone, String baby_name, String baby_sex_code, 
//		String baby_birthday, String info_source_code, String card_level_code, String coupon_code, String apply_way_code,
//		String kids_park_id, String interest_service, String assistant_id, String assistant_name, String auditor_id, 
//		String auditor_name, String desc, String guardians 
		
		
		//ApplyCard a=new ApplyCard();
		Map<String, Object> m = new HashMap<String, Object>();
		try {
			if(obj!=null){ 
				m = memberCardApiService.applyCardBackground(MyTools.ObjectToString(obj.get("real_name")), 
						MyTools.ObjectToString(obj.get("phone")), MyTools.ObjectToString(obj.get("info_source_code")), 
						MyTools.ObjectToString(obj.get("coupon_code")), MyTools.ObjectToString(obj.get("apply_way_code")), 
						MyTools.ObjectToString(obj.get("kids_park_id")), MyTools.ObjectToString(obj.get("interest_service")), MyTools.ObjectToString(obj.get("assistant_id")),
						MyTools.ObjectToString(obj.get("assistant_name")), 
						MyTools.ObjectToString(obj.get("auditor_id")), MyTools.ObjectToString(obj.get("auditor_name")), MyTools.ObjectToString(obj.get("desc")),
						MyTools.ObjectToString(obj.get("operator_id")),MyTools.ObjectToString(obj.get("operator_name")),MyTools.ObjectToString(obj.get("consume_recommend_id")),MyTools.ObjectToString(obj.get("consume_recommend_name")),		
						(List<Map<String,Object>>)obj.get("guardians"),(List<Map<String,Object>>)obj.get("babies"),(List<Map<String,Object>>)obj.get("packages"),MyTools.ObjectToString(obj.get("address")),MyTools.ObjectToString(obj.get("zipcode")),
						MyTools.ObjectToString(obj.get("apply_type")),MyTools.ObjectToString(obj.get("family_phone")),MyTools.ObjectToString(obj.get("consume_recommend_deptID")),MyTools.ObjectToString(obj.get("consume_recommend_dept_name"))
						,MyTools.ObjectToString(obj.get("initialOperatorID")),MyTools.ObjectToString(obj.get("initialOperatorName")),
						MyTools.ObjectToString(obj.get("applicationID")), MyTools.ObjectToString(obj.get("earnestMoney")),request);

			}else{
	//		m = memberCardApiService.applyCardBackground(real_name, phone, baby_name, baby_sex_code, baby_birthday, info_source_code, card_level_code, coupon_code, apply_way_code, kids_park_id, interest_service, assistant_id, assistant_name, auditor_id, auditor_name, desc, guardians);
			}		
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}
		//String callback=null;
		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	@OaRestPermission(value="/consumeBackground/courseSignIn")
	@RequestMapping(value = "/applyCardBackground",headers = {"content-type=application/json"})
	@ResponseBody
	public Object applyCardBackground2(@RequestBody Map<String,Object> obj,String callback,HttpServletRequest request) {

		Map<String, Object> m = new HashMap<String, Object>();
		String recharge_amount = MyTools.ObjectToString(obj.get("recharge_amount"));
		String user_get_amount =MyTools.ObjectToString(obj.get("user_get_amount"));
		if(user_get_amount!=null){
			recharge_amount=user_get_amount;
		}
		
		try {
			if(obj!=null){ 
				m = memberCardApiService.applyCardBackground2(MyTools.ObjectToString(obj.get("real_name")), 
						MyTools.ObjectToString(obj.get("phone")), MyTools.ObjectToString(obj.get("info_source_code")), 
						MyTools.ObjectToString(obj.get("coupon_code")), MyTools.ObjectToString(obj.get("apply_way_code")), 
						MyTools.ObjectToString(obj.get("kids_park_id")), MyTools.ObjectToString(obj.get("interest_service")), MyTools.ObjectToString(obj.get("assistant_id")),
						MyTools.ObjectToString(obj.get("assistant_name")), 
						MyTools.ObjectToString(obj.get("auditor_id")), MyTools.ObjectToString(obj.get("auditor_name")), MyTools.ObjectToString(obj.get("desc")),
						MyTools.ObjectToString(obj.get("operator_id")),MyTools.ObjectToString(obj.get("operator_name")),MyTools.ObjectToString(obj.get("consume_recommend_id")),MyTools.ObjectToString(obj.get("consume_recommend_name")),		
						(List<Map<String,Object>>)obj.get("guardians"),(List<Map<String,Object>>)obj.get("babies"),(List<Map<String,Object>>)obj.get("packages"),MyTools.ObjectToString(obj.get("address")),MyTools.ObjectToString(obj.get("zipcode")),
						MyTools.ObjectToString(obj.get("apply_type")),MyTools.ObjectToString(obj.get("family_phone")),MyTools.ObjectToString(obj.get("consume_recommend_deptID")),MyTools.ObjectToString(obj.get("consume_recommend_dept_name"))
						,MyTools.ObjectToString(obj.get("initialOperatorID")),MyTools.ObjectToString(obj.get("initialOperatorName")),						
						MyTools.ObjectToString(obj.get("earnestMoney")),
						
						MyTools.ObjectToString(obj.get("order_payment")),
						MyTools.ObjectToString(obj.get("payment_amount")),MyTools.ObjectToString(obj.get("card_number")),
						MyTools.ObjectToString(obj.get("card_out_number")),MyTools.ObjectToString(obj.get("contract_name")),
						MyTools.ObjectToString(obj.get("begin_time")),MyTools.ObjectToString(obj.get("end_time")),
						MyTools.ObjectToString(obj.get("file"))
						,
						
						MyTools.ObjectToString(obj.get("rechargeCardCategory")),recharge_amount,
						MyTools.ObjectToString(obj.get("point")),
						MyTools.ObjectToString(obj.get("totalDueAmount")),
						MyTools.ObjectToString(obj.get("isDiscount")),
						MyTools.ObjectToString(obj.get("discount_type")),
						request);
	

			}		
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	//申请卡支付
/*	@RequestMapping(value = "/applyCardPayment")
	@ResponseBody
	public Object applyCardPayment(String order_payment,String c_membercard_applicationID,String payment_amount,String card_number,String card_out_number,
			String contract_name,String begin_time,String end_time,String file,String OperatorID,String OperatorName,
			String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {
			m = memberCardApiService.applyCardPayment(order_payment,c_membercard_applicationID, payment_amount, card_number,
					card_out_number,contract_name,begin_time,end_time,file,OperatorID,OperatorName,null);								
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();
		}
		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}*/
	
	//申请卡支付
	@RequestMapping(value = "/applyCardPaymentRemain")
	@ResponseBody
	public Object applyCardPaymentRemain(int isPaidAll,String order_payment,String contractID,
			String isDiscount,String callback) {

		BaseResult br = null;
		try {
			br = memberCardApiService.applyCardPaymentRemain(isPaidAll,order_payment,contractID,isDiscount);		
		} catch (Exception e) {
			br=new BaseResult("0","系统异常");
			e.printStackTrace();
		}
		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, br);
		} else {
			return br;
		}
	}

	@RequestMapping(value = "/updateApplication")
	@ResponseBody
	public Object ApplicationUpdate(@RequestBody ApplicationUpdate application,BindingResult result,String callback,HttpServletRequest request) {
		
		
		Map<String, Object> m = new HashMap<String, Object>();
		Object obj=null;
		try {
		
			obj=memberCardApiService.updateapply(application, result,request);
				
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();
			return m;

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, obj);
		} else {
			return obj;
		}
	}

	@RequestMapping(value = "/getFamilyDetail")
	@ResponseBody
	public Object getFamilyDetail(String phone,String card_number,String member_number,String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {
			String a=ApplicationUtils.Object2String(null);
			System.out.println(a);
			
			m = memberCardApiService.getFamilyDetail(phone,card_number,member_number);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	@RequestMapping(value = "/getContractByID")
	@ResponseBody
	public Object getContractByID(String contractID,String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.getContractByID(contractID);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	@RequestMapping(value = "/getApplicationByID")
	@ResponseBody
	public Object getApplicationByID(String applicationID,String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.getApplicationByID(applicationID);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	
	
	@RequestMapping(value = "/checkCoupon")
	@ResponseBody
	public Object checkCoupon(String coupon_code,String phone,String c_user_id,String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = memberCardApiService.checkCoupon(phone,c_user_id,coupon_code);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();
		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}
	}
	
	@RequestMapping(value = "/updateContract")
	@ResponseBody
	public Object updateContract(@RequestBody ContractUpdate contractUpdate,String callback,HttpServletRequest request) {
		ShopOaSessionUtil.setOaSession(request);

		BaseResult br = null;
		try {

			br = memberCardApiService.updateContract(contractUpdate,request);
					
		} catch (Exception e) {
			br = new BaseResult("0","系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, br);
		} else {
			return br;
		}
	}
	
}

